package com.magold.logic.region.airflow;

import org.andengine.entity.IEntityFactory;
import org.andengine.entity.shape.IAreaShape;
import org.andengine.extension.physics.box2d.PhysicsWorld;

import com.magold.sprite.IMultiTextureSprite;

public class AirflowParticleFactory implements IEntityFactory<IMultiTextureSprite> {
	private IParticleRecycleHandler<IMultiTextureSprite> mRecycleHandler;
	private PhysicsWorld mWorld;
	private IAreaShape mRangeShape;
	
	public AirflowParticleFactory(IAreaShape pRangeShape, IParticleRecycleHandler<IMultiTextureSprite> pRecycleHandler) {
		this(pRangeShape, pRecycleHandler, null);
	}
	
	public AirflowParticleFactory(IAreaShape pRangeShape, IParticleRecycleHandler<IMultiTextureSprite> pRecycleHandler, PhysicsWorld pWorld) {
		mRangeShape = pRangeShape;
		mRecycleHandler = pRecycleHandler;
		mWorld = pWorld;
	}
	
	@Override
	public IMultiTextureSprite create(float pX, float pY) {
		ParticleLogic logic = new ParticleLogic(mRecycleHandler);
		logic.createSceneData(pX, pY, mRangeShape.getRotation(), 1, null);
		logic.createPhysicsData(mWorld);
		
		return logic.mSprite;
	}

	public void setPhysicesWorld(PhysicsWorld pWorld) {
		mWorld = pWorld;
	}

	public float getParticleHeight() {
		return ParticleLogic.sTexture.getHeight();
	}
	
	public float getParticleWidth() {
		return ParticleLogic.sTexture.getWidth();
	}
	
}
